# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Simon Sapin <simon dot sapin at exyr dot org>
# Contributor: Kyle Keen <keenerd@gmail.com>

pkgname=python-rencode
pkgver=1.0.6
pkgrel=8
pkgdesc="A Module similar to bencode from the BitTorrent project"
url="https://github.com/aresch/rencode"
license=('GPL')
arch=('loong64' 'x86_64')
depends=('python')
makedepends=('cython' 'python-setuptools')
checkdepends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/aresch/rencode/archive/v$pkgver.tar.gz"
        remove-wheel.patch)
sha512sums=('f04de4d3a83aed916bdc4b7a8ca772655e9324d0531ee882cb7d2a1e92b397bdcec8497bf02939e0a806886ecc62ed2e7319dfee054dad1b69052157f0959e8f'
            '3062866d4fc890a2df8c8c261a5f67604c9fca67afb5526a24b599332d65ab093253e67c3a117a118f85144e3e32caf939c307f32668795f2eb7a7087572c1a8')

prepare() {
  cd "$srcdir"/rencode-$pkgver
  patch -Np1 -i ../remove-wheel.patch
}

build() {
  cd "$srcdir"/rencode-$pkgver
  python setup.py build
}

check() {
  cd "$srcdir"/rencode-$pkgver
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-cpython-311" py.test
}

package() {
  cd rencode-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
}
